//////////////////////////////////////////////////////////////////////
// peg_def.h
//////////////////////////////////////////////////////////////////////

#pragma once
#include "peg_def.h"

using namespace peg_templ;

typedef And< Char<'\r'>, Char<'\n'> > itemend;

typedef And< CHAR_E, CHAR_V, CHAR_E,\
             CHAR_N, CHAR_T > event_p;
typedef And< event_p, Char<':'>, Char<' '>,\
             PlusRepeat< Alpha >, Char<'\r'>,Char<'\n'> > event_s;

typedef And< CHAR_R, CHAR_E, CHAR_S, CHAR_P,\
             CHAR_O, CHAR_N, CHAR_S, CHAR_E > response_p;
typedef And< response_p, Char<':'>, Char<' '>,\
             PlusRepeat< Or<DIGIT, Alpha, Char<' '> > >,\
             itemend > response_s;

typedef And< CHAR_P, CHAR_R, CHAR_I,\
             CHAR_V, CHAR_I, CHAR_L,\
             CHAR_E, CHAR_G, CHAR_E > privilege_p;
typedef And< privilege_p, Char<':'>, Char<' '>,\
             PlusRepeat< Or< Alpha, Char<','> > >,\
             itemend > privilege_s;

typedef And< CHAR_C, CHAR_O, CHAR_N, CHAR_F, CHAR_E,\
             CHAR_R, CHAR_E, CHAR_N, CHAR_C, CHAR_E,\
             CHAR_N, CHAR_A, CHAR_M, CHAR_E> conferencename_p;
typedef And< conferencename_p, Char<':'>, Char<' '>,\
             PlusRepeat<DIGIT>, itemend > conferencename_s;

typedef And< CHAR_U, CHAR_N, CHAR_I, CHAR_Q,\
             CHAR_U, CHAR_E, CHAR_I, CHAR_D> uniqueid_p;
typedef And< uniqueid_p, Char<':'> ,Char<' '> ,\
             PlusRepeat< Or< DIGIT, Char<'.'> > >,\
             itemend  > uniqueid_s;

typedef And< CHAR_K, CHAR_E, CHAR_Y > key_p;
typedef And< key_p, Char<':'> ,Char<' '> ,\
             PlusRepeat< Or< DIGIT, Alpha > >,\
             itemend  > key_s;

typedef And<CHAR_M,CHAR_E,CHAR_M,CHAR_B,CHAR_E,CHAR_R> member_p;
typedef And< member_p, Char<':'>, Char<' '>, \
             PlusRepeat<DIGIT>, itemend > member_s;

typedef And< CHAR_F, CHAR_L, CHAR_A, CHAR_G, CHAR_S> flags_p;
typedef And< flags_p, Char<':'>, Char<' '>, \
             PlusRepeat<Alpha>, itemend > flags_s;

typedef And< CHAR_C, CHAR_H, CHAR_A, CHAR_N,\
             CHAR_N, CHAR_E, CHAR_L > channel_p;
typedef And< channel_p, Char<':'>, Char<' '>,\
             PlusRepeat< Or< Alpha, DIGIT, Char<'/'>, Char<'-'> > >,\
             itemend > channel_s;

typedef And< CHAR_C, CHAR_A, CHAR_L, CHAR_L,\
             CHAR_E, CHAR_R, CHAR_I, CHAR_D> callerid_p;
typedef And< callerid_p, Char<':'>, Char<' '>,\
             PlusRepeat<DIGIT>, itemend > callerid_s;

typedef And< CHAR_C, CHAR_A, CHAR_L, CHAR_L,\
             CHAR_E, CHAR_R, CHAR_I, CHAR_D,\
             CHAR_N, CHAR_A, CHAR_M, CHAR_E> calleridname_p;
typedef And< calleridname_p, Char<':'>, Char<' '>,\
             PlusRepeat<DIGIT>, itemend > calleridname_s;

typedef And< CHAR_C, CHAR_O, CHAR_U,\
             CHAR_N,CHAR_T> count_p;
typedef And< count_p, Char<':'>, Char<' '>,\
             PlusRepeat<DIGIT>, itemend > count_s;

typedef And< CHAR_S, CHAR_T, CHAR_A,\
             CHAR_T, CHAR_E > state_p;
typedef And< state_p, Char<':'>, Char<' '>,\
             PlusRepeat< Or<DIGIT,Alpha,Char<' '> > >,\
             itemend > state_s;

typedef And< CHAR_K, CHAR_E, CHAR_Y > key_p;
typedef And< key_p, Char<':'>, Char<' '>,\
             PlusRepeat< Or<DIGIT,Alpha > >,\
             itemend > key_s;

typedef And< CHAR_D, CHAR_U, CHAR_R, CHAR_A,\
             CHAR_T, CHAR_I, CHAR_O, CHAR_N > duration_p;
typedef And< duration_p, Char<':'>, Char<' '>,\
             PlusRepeat< DIGIT >, itemend > duration_s;

typedef And< CHAR_M, CHAR_O, CHAR_D, CHAR_E,\
             CHAR_R, CHAR_A, CHAR_T, CHAR_O,\
             CHAR_R, CHAR_S > moderators_p;
typedef And< moderators_p, Char<':'>, Char<' '>,\
             PlusRepeat< Or<Alpha, DIGIT> >, itemend > moderators_s;

typedef And< CHAR_M, CHAR_U, CHAR_T,\
             CHAR_E > mute_p;
typedef And< mute_p, Char<':'>, Char<' '>,\
             PlusRepeat<DIGIT>, itemend > mute_s;

typedef And< CHAR_M, CHAR_E, CHAR_S,\
             CHAR_S, CHAR_A, CHAR_G, CHAR_E > message_p;
typedef And< message_p, Char<':'>, Char<' '>,\
             PlusRepeat< Or<DIGIT, Alpha, Char<' '> > >,\
             itemend > message_s;

typedef And< CHAR_S, CHAR_T, CHAR_A,\
             CHAR_T, CHAR_U, CHAR_S > status_p;
typedef And< status_p, Char<':'>, Char<' '>,\
             PlusRepeat< Or<DIGIT, Alpha, Char<' '> > >,\
             itemend > status_s;

typedef And< CHAR_C, CHAR_O, CHAR_N, CHAR_F,\
             CHAR_E, CHAR_R, CHAR_E, CHAR_N,\
             CHAR_C, CHAR_E, CHAR_L, CHAR_E,\
             CHAR_A, CHAR_V, CHAR_E > conferenceleave_p;

typedef And< CHAR_C, CHAR_O, CHAR_N, CHAR_F,\
             CHAR_E, CHAR_R, CHAR_E, CHAR_N,\
             CHAR_C, CHAR_E, CHAR_S, CHAR_T,\
             CHAR_A, CHAR_T, CHAR_E > conferencestate_p;

typedef And< CHAR_C, CHAR_O, CHAR_N, CHAR_F,\
             CHAR_E, CHAR_R, CHAR_E, CHAR_N,\
             CHAR_C, CHAR_E, CHAR_J, CHAR_O,\
             CHAR_I, CHAR_N > conferencejoin_p;

typedef And< CHAR_C, CHAR_O, CHAR_N, CHAR_F,\
             CHAR_E, CHAR_R, CHAR_E, CHAR_N,\
             CHAR_C, CHAR_E, CHAR_D, CHAR_T,\
             CHAR_M, CHAR_F > conferencedtmf_p;

typedef And< CHAR_N, CHAR_E, CHAR_W, CHAR_C,\
             CHAR_A, CHAR_L, CHAR_L, CHAR_E,\
             CHAR_R, CHAR_I, CHAR_D > newcallerid_p;

typedef And< CHAR_N, CHAR_E, CHAR_W, CHAR_A,\
             CHAR_C, CHAR_C, CHAR_O, CHAR_U,\
             CHAR_N, CHAR_T, CHAR_C, CHAR_O,\
             CHAR_D, CHAR_E > newaccountcode_p;

typedef And< CHAR_E, CHAR_X, CHAR_T, CHAR_E,\
             CHAR_N, CHAR_S, CHAR_I, CHAR_O,\
             CHAR_N, CHAR_S, CHAR_T, CHAR_A,\
             CHAR_T, CHAR_U, CHAR_S > extensionstatus_p;

typedef And< CHAR_N, CHAR_E, CHAR_W,\
             CHAR_S, CHAR_T, CHAR_A,\
             CHAR_T, CHAR_E > newstate_p;

typedef And< CHAR_N, CHAR_E, CHAR_W,\
             CHAR_E, CHAR_X, CHAR_T,\
             CHAR_E, CHAR_N > newexten_p;

typedef And< CHAR_V, CHAR_A, CHAR_R,\
             CHAR_S, CHAR_E, CHAR_T > varset_p;

typedef And< CHAR_R, CHAR_T, CHAR_C,\
             CHAR_P, CHAR_S, CHAR_E,\
             CHAR_N, CHAR_T > rtcpsent_p;

typedef And< CHAR_H, CHAR_A, CHAR_N,\
             CHAR_G, CHAR_U, CHAR_P > hangup_p;

typedef And< CHAR_N, CHAR_E, CHAR_W, CHAR_C,\
             CHAR_H, CHAR_A, CHAR_N, CHAR_N,\
             CHAR_E, CHAR_L > newchannel_p;

typedef And< CHAR_A, CHAR_S, CHAR_T, CHAR_E,\
              CHAR_R, CHAR_I, CHAR_S, CHAR_K >
              asterisk_p;

typedef And< CHAR_C, CHAR_A, CHAR_L, CHAR_L >
              call_p;
typedef And< CHAR_M, CHAR_A, CHAR_N, CHAR_A,\
              CHAR_G, CHAR_E, CHAR_R > manager_p;

typedef And< asterisk_p, Char<' '>, call_p, Char<' '>, manager_p >
             hello_p;
typedef And< hello_p,\
              DIGIT, Char<'.'>, DIGIT, crcn > hello_s;

typedef And< DIGIT, Char<'.'>, DIGIT > version_s;

// command type
typedef FindRepeat< hello_p > hello_f;
typedef FindRepeat< event_s > event_f;
typedef FindRepeat< response_s > response_f;

// cmd_event type
typedef FindRepeat< conferencestate_p > conferencestate_f;
typedef FindRepeat< conferenceleave_p > conferenceleave_f;
typedef FindRepeat< conferencejoin_p > conferencejoin_f;
typedef FindRepeat< conferencedtmf_p > conferencedtmf_f;
typedef FindRepeat< newcallerid_p > newcallerid_f;
typedef FindRepeat< newaccountcode_p > newaccountcode_f;
typedef FindRepeat< extensionstatus_p > extensionstatus_f;
typedef FindRepeat< newstate_p > newstate_f;
typedef FindRepeat< newexten_p > newexten_f;
typedef FindRepeat< varset_p > varset_f;
typedef FindRepeat< rtcpsent_p > rtcpsent_f;
typedef FindRepeat< hangup_p > hangup_f;
typedef FindRepeat< newchannel_p > newchannel_f;
// field
typedef FindRepeat< channel_s > channel_f;
typedef FindRepeat< flags_s > flags_f;
typedef FindRepeat< conferencename_s > conferencename_f;
typedef FindRepeat< count_s > count_f;
typedef FindRepeat< key_s > key_f;
typedef FindRepeat< mute_s > mute_f;
typedef FindRepeat< member_s > member_f;
typedef FindRepeat< callerid_s > callerid_f;
typedef FindRepeat< calleridname_s > calleridname_f;
typedef FindRepeat< state_s > state_f;
typedef FindRepeat< uniqueid_s > uniqueid_f;
typedef FindRepeat< duration_s > duration_f;
typedef FindRepeat< moderators_s > moderators_f;
typedef FindRepeat< privilege_s > privilege_f;
typedef FindRepeat< message_s > message_f;
typedef FindRepeat< status_s > status_f;
typedef FindRepeat< key_s > key_f;
typedef FindRepeat< version_s > version_f;

// Configuration Prefix
typedef And< CHAR_L, CHAR_I, CHAR_S,\
             CHAR_T, Char<':'> > list_p;
typedef And< CHAR_O, CHAR_U, CHAR_T,\
             CHAR_C, CHAR_A, CHAR_L,\
             CHAR_L, Char<':'> > outcall_p;
typedef And< CHAR_M, CHAR_A, CHAR_X,\
             CHAR_C, CHAR_A, CHAR_L,\
             CHAR_L, Char<':'> > maxcall_p;
typedef And< CHAR_R, CHAR_E, CHAR_C,\
             CHAR_O, CHAR_R, CHAR_D,\
             Char<':'> > record_p;
typedef And< CHAR_W, CHAR_A, CHAR_I,\
             CHAR_T, CHAR_T, CHAR_I,\
             CHAR_M, CHAR_E, Char<':'> > waittime_p;
typedef And< CHAR_A, CHAR_S, CHAR_T,\
             CHAR_U, CHAR_S, CHAR_E,\
             CHAR_R, Char<':'> > astuser_p;
typedef And< CHAR_O, CHAR_U, CHAR_T,\
             CHAR_C, CHAR_H, CHAR_A,\
             CHAR_N, CHAR_N, CHAR_A,\
             CHAR_M, CHAR_E, Char<':'> > outchanname_p;

// Configuration Data
typedef FindRepeat< list_p >    list_f;
typedef FindRepeat< outcall_p > outcall_f;
typedef FindRepeat< maxcall_p > maxcall_f;
typedef FindRepeat< record_p >  record_f;
typedef FindRepeat< waittime_p >  waittime_f;
typedef FindRepeat< astuser_p > astuser_f;
typedef FindRepeat< outchanname_p > outchanname_f;

//////////////////////////////////////////////////////////////////////
